package com.rt.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rt.common.annotation.Log;
import com.rt.common.core.controller.BaseController;
import com.rt.common.core.domain.AjaxResult;
import com.rt.common.enums.BusinessType;
import com.rt.system.domain.RtAssemblyDifficulty;
import com.rt.system.service.IRtAssemblyDifficultyService;
import com.rt.common.utils.poi.ExcelUtil;
import com.rt.common.core.page.TableDataInfo;

/**
 * 策略难易度Controller
 * 
 * @author Yg
 * @date 2022-05-05
 */
@RestController
@RequestMapping("/system/assemblydifficulty")
public class RtAssemblyDifficultyController extends BaseController
{
    @Autowired
    private IRtAssemblyDifficultyService rtAssemblyDifficultyService;

    /**
     * 查询策略难易度列表
     */
    @PreAuthorize("@ss.hasPermi('system:difficulty:list')")
    @GetMapping("/list")
    public TableDataInfo list(RtAssemblyDifficulty rtAssemblyDifficulty)
    {
        startPage();
        List<RtAssemblyDifficulty> list = rtAssemblyDifficultyService.selectRtAssemblyDifficultyList(rtAssemblyDifficulty);
        return getDataTable(list);
    }

    /**
     * 导出策略难易度列表
     */
    @PreAuthorize("@ss.hasPermi('system:difficulty:export')")
    @Log(title = "策略难易度", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RtAssemblyDifficulty rtAssemblyDifficulty)
    {
        List<RtAssemblyDifficulty> list = rtAssemblyDifficultyService.selectRtAssemblyDifficultyList(rtAssemblyDifficulty);
        ExcelUtil<RtAssemblyDifficulty> util = new ExcelUtil<RtAssemblyDifficulty>(RtAssemblyDifficulty.class);
        return util.exportExcel(list, "策略难易度数据");
    }

    /**
     * 获取策略难易度详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:difficulty:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rtAssemblyDifficultyService.selectRtAssemblyDifficultyById(id));
    }

    /**
     * 新增策略难易度
     */
    @PreAuthorize("@ss.hasPermi('system:difficulty:add')")
    @Log(title = "策略难易度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RtAssemblyDifficulty rtAssemblyDifficulty)
    {
        return toAjax(rtAssemblyDifficultyService.insertRtAssemblyDifficulty(rtAssemblyDifficulty));
    }

    /**
     * 修改策略难易度
     */
    @PreAuthorize("@ss.hasPermi('system:difficulty:edit')")
    @Log(title = "策略难易度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RtAssemblyDifficulty rtAssemblyDifficulty)
    {
        return toAjax(rtAssemblyDifficultyService.updateRtAssemblyDifficulty(rtAssemblyDifficulty));
    }

    /**
     * 删除策略难易度
     */
    @PreAuthorize("@ss.hasPermi('system:difficulty:remove')")
    @Log(title = "策略难易度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtAssemblyDifficultyService.deleteRtAssemblyDifficultyByIds(ids));
    }
}
